#include "mandelbrotthread.h"

MandelbrotThread::MandelbrotThread(QObject *parent)
    : RenderThread(parent)
{
}

int MandelbrotThread::pointIteration(Complex z, int k, const Complex & /* c */)
{
    int i;
    Complex z0 = z;
    for (i = 0; z.abs() <= 2 && i < k; ++i) {
        z = (z^2) + z0;
	//z = (z^4) - (z0*(z^2)) + z0;
    }
    return i;
}

int MandelbrotThread::pointIteration(double x, double y, int k, double /* cr */, double /* ci */)
{
    int i;
    double x0 = x;
    double y0 = y;

    for (i = 0; i < k; ++i) {
        double x2 = x*x;
        double y2 = y*y;
        if (x2 + y2 > 4)
            break;
        y = 2*x*y + y0;
        x = x2 - y2 + x0;
    }

    return i;
}
